import type { Option } from '../type';
export {
  default as checkType,
  isArray,
  isBoolean,
  isDate,
  isError,
  isFunction,
  isNull,
  isNullOrUndefined,
  isNumber,
  isObject,
  isPrimitive,
  isRegExp,
  isString,
  isSymbol,
  isUndefined,
} from './checkType';
export { default as createUniqueId } from './createUniqueId';
export { default as deepClone } from './deepClone';
export { default as getEffectiveValue } from './getEffectiveValue';
export { default as getFormat } from './getFormat';
export { default as getPrefixCls } from './getPrefixCls';

export const getOption = (value: any, options: Option[]) => {
  const defaultOption: Option = { label: '', value: '' };
  for (let option of options) {
    if (option.value === value) {
      return option;
    }
  }
  return defaultOption;
};
export function getElementStyle(element: any): CSSStyleDeclaration {
  if (window.getComputedStyle) {
    return window.getComputedStyle(element, null);
  } else {
    return element.currentStyle;
  }
}

export function getElementSize(
  element: Element,
  size: 'width' | 'height' = 'width',
) {
  if (element) {
    const sizeStyle = getElementStyle(element)[size];
    return Number(sizeStyle.replace('px', ''));
  }
  return 0;
}
